﻿package com.mui.manager
{
    import com.gengine.global.*;
    import com.mui.controls.*;
    import flash.events.*;

    public class ToolTipSprite extends GSprite implements IToolTipItem
    {
        private var _reactionTime:int = 500;
        protected var _toolTipData:Object;

        public function ToolTipSprite()
        {
            return;
        }// end function

        protected function judgeToolTip(event:Event = null) : void
        {
            if (event && event.type == Event.ADDED_TO_STAGE && this.toolTipData || !event && this.toolTipData && Global.stage.contains(this))
            {
                ToolTipsManager.register(this);
            }
            else
            {
                ToolTipsManager.unregister(this);
            }
            return;
        }// end function

        public function get toolTipData()
        {
            if (this._toolTipData is Function)
            {
                return (this._toolTipData as Function).apply();
            }
            return this._toolTipData;
        }// end function

        public function set toolTipData(param1) : void
        {
            this._toolTipData = param1;
            this.judgeToolTip();
            return;
        }// end function

        public function get reactionTime() : int
        {
            return this._reactionTime;
        }// end function

        public function set reactionTime(param1:int) : void
        {
            this._reactionTime = param1;
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this.mouseEnabled = true;
            this.configEventListener(Event.ADDED_TO_STAGE, this.judgeToolTip);
            this.configEventListener(Event.REMOVED_FROM_STAGE, this.judgeToolTip);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            ToolTipsManager.unregister(this);
            this._reactionTime = 500;
            this._toolTipData = null;
            return;
        }// end function

    }
}
